﻿using LJX.SmartPark.Domain.Base;
using LJX.SmartPark.Domain.IotInfo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJX.SmartPark.Service.Repository
{
    public interface IRepository<TEntity> where TEntity : KeyEntity
    {
        /// <summary>
        /// 获取所有的数据
        /// </summary>
        /// <returns></returns>
        Task<List<TEntity>> GetAllListAsync();

        /// <summary>
        /// 获取集合的Query
        /// </summary>
        /// <returns></returns>
        IQueryable<TEntity> GetListQuery();

        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<TEntity> GetEntityByIdAsync(KeyEntity key);

        /// <summary>
        /// 批量删除实体
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(params TEntity[] entities);

        /// <summary>
        /// 返回总数
        /// </summary>
        /// <returns></returns>
        int GetCount();

        /// <summary>
        /// 批量插入数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> InsertAsync(params TEntity[] entitiies);

        /// <summary>
        /// 插入单条数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> InsertAsyncById(TEntity entity);

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(TEntity entity);

        /// <summary>
        /// 删除单条数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> DeleteByIdAsync(KeyEntity key);
    }
}
